import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import '@/style/element_visiable.scss'
import '@/style/theme.scss'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

// 引入gin-vue-admin前端初始化相关内容
import '@/core/gin-vue-admin'
// 引入公共组件
import commonComponent from '@/components/index.js'
// 引入本系统公共组件
import crmComponent from '@CRM/components/index.js'

import { alertBox, confirmBox, message, promptInput } from '@/utils/customMessage.js'
import api from '@CRM/api/index.js'

// 引入封装的router
import router from './router/index'
import run from '@/core/gin-vue-admin.js'
import auth from '@CRM/directive/auth'
import table from '@CRM/directive/table'

import './permission'
import { crmStore } from './store/index'

// 全局方法
import { dateFormat } from '@/utils/date.js'
import { getProductName, moneyFormat } from '@/utils/commonFun.js'
import { isInteger } from '@/utils/validate.js'
import { getCascaderAreaData, getServeAreaData } from '@/utils/areaFuc.js'
import { getCrmDict, getCrmDictLabel } from '@/utils/dictionary.js'

// 消息
import '@/utils/socket.js'

import App from './App.vue'

const app = createApp(App)
app.config.productionTip = false
// message及确认框
app.config.globalProperties.customMessage = message
app.config.globalProperties.alertBox = alertBox
app.config.globalProperties.confirmBox = confirmBox
app.config.globalProperties.promptInput = promptInput
// 格式化时间
app.config.globalProperties.dateFormat = dateFormat
// 金额格式化
app.config.globalProperties.moneyFormat = moneyFormat
// 获取产品名称
app.config.globalProperties.getProductName = getProductName

// 地区数据处理
app.config.globalProperties.getServeAreaData = getServeAreaData
app.config.globalProperties.getCascaderAreaData = getCascaderAreaData
// 获取字典
app.config.globalProperties.getCrmDict = getCrmDict
// 字典获取label
app.config.globalProperties.getLabel = getCrmDictLabel
// 保留两位小数
app.config.globalProperties.isInteger = isInteger

app.use(run)
  .use(auth)
    .use(table)
  .use(crmStore)
  .use(router)
  .use(ElementPlus, { locale: zhCn }).mount('#app')

commonComponent(app)
crmComponent(app)

app.provide('api', api)

export default app
